<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // 获取0-63随机长度的数字字母的组合
    const randomNumber = length => {
      const pattern = '1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLOMNOPQRSTUVWXYZ=';
      let key = '';
      for (var i = 0; i < length; i++) { // 感觉i从0取值更好
        key += pattern[Math.round(Math.random() * 63)];    //生成php随机数
      }
      return key;
    }
    console.log(randomNumber(2));
  </script>
</body>

</html>